package com.atguigu.eduservice.controller;

import com.atguigu.commonutils.result.R;
import com.atguigu.eduservice.service.EduSubjectService;
import com.atguigu.eduservice.entity.subject.OneSubject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author kabuda
 * @create 2023-05-02 8:37
 */
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService eduSubjectService;

    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        eduSubjectService.saveSubject(file);
        return R.ok();
    }
    @GetMapping("downSubjectExcel")
    public void downSubjectExcel(HttpServletResponse response){
        eduSubjectService.exportExcel(response);
    }
    @GetMapping("getNestedTreeList")
    public R getNestedTreeList(){
       List<OneSubject>  list=eduSubjectService.getNestedTreeList();
       return R.ok().data("items",list);
    }

}
